Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use random seed for xxhash #752

Merged
merged 2 commits into from
Feb 27, 2025
Merged

Conversation

varungup90
Copy link
Collaborator

Pull Request Description

Generates random seed value for every gateway initialization

Related Issues

Resolves: #749

@Jeffwan
Copy link
Collaborator

Jeffwan commented Feb 26, 2025

@varungup90 can you squash the commits to pass DCO?

Signed-off-by: Varun Gupta <[email protected]>
@Jeffwan Jeffwan merged commit fe9f91c into vllm-project:main Feb 27, 2025
11 checks passed
@kexinoh
Copy link

kexinoh commented Feb 27, 2025

Why not directly generate it using cryptographic randomness? That would be more compliant with the standards.

@varungup90
Copy link
Collaborator Author

Why not directly generate it using cryptographic randomness? That would be more compliant with the standards.

It requires same seed to generate same hash value for prompt's prefix.

@kexinoh
Copy link

kexinoh commented Feb 28, 2025

For security-focused scenarios in Go, it might be better to use the crypto/rand package instead of math/rand. You could try something like this:

import (
    "crypto/rand"
    "encoding/binary"
)

func generateSecureSeed() (uint64, error) {
    var seed uint64
    if err := binary.Read(rand.Reader, binary.BigEndian, &seed); err != nil {
        return 0, err
    }
    return seed, nil
}

This complies with the random number generation specifications. In fact, rand.New(rand.NewSource(time.Now().Unix())) should never be used under any circumstances.

@varungup90
Copy link
Collaborator Author

@kexinoh Sounds good, you can send a PR to add generateSecureSeed method in pkg/util.

@varungup90 varungup90 deleted the random-seed-xxhash branch March 4, 2025 22:28
xieus pushed a commit that referenced this pull request Mar 5, 2025
Signed-off-by: Varun Gupta <[email protected]>
Signed-off-by: Liguang Xie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xxhash64 Collision Risks and Fixes in aibrix Clusters​
3 participants